import axios from '../../utils/axios';
import api from '../../api';
import qs from 'qs';

export function getCusHighSeaM({ currentPage, pageSize }) {
    return new Promise((resovle, reject) => {
        axios({
            url: api.customerhighseaApi.customerhighsea.CUSTOMERHIGHSEA_CUSMANAGE,
            params: { currentPage, pageSize},
            method: 'get'
        }).then((data) => {
            resovle(data)
        }).catch((err) => {
            reject(err)
        })
    })
}

export function getCusHighSeaRes(params) {
    return new Promise((resovle, reject) => {
        axios({
            url: api.customerhighseaApi.customerhighsea.CUSTOMERHIGHSEA_SEARCH,
            method: 'get',
            params,
            paramsSerializer: params => {
                return qs.stringify(params, {
                    arrayFormat: 'repeat' //转换后的数组格式
                })
            },
        }).then((res) => {
            resovle(res)
        }).catch((err) => {
            reject(err)
        })
    })
}
export function delList({customer_id}) {
    return new Promise((resovle, reject) => {
        axios({
            url: api.customerhighseaApi.customerhighsea.CUSTOMERHIGHSEA_DEL,
            method: 'post',
            params: {customer_id}
        }).then((res) => {
            resovle(res)
        }).catch((err) => {
            reject(err)
        })
    })
}

//待审核申请
export function pendingAudit({currentPage, pageSize }) {
    return new Promise((resovle, reject) => {
        axios({
            url: api.customerhighseaApi.customerhighsea.CUSTOMERHIGHSEA_PENDINGAUDIT,
            params:{currentPage, pageSize },
            method: 'get'
        }).then((data) => {
            resovle(data)
        }).catch((err) => {
            reject(err)
        })
    })
}

//审核通过
export function applyPass(params) {
    return new Promise((reslove, reject) => {
        axios({
            url: api.customerhighseaApi.customerhighsea.CUSTOMERHIGHSEA_CUSMANAGE_AUDIT_APPLY_PASS,
            method: 'post',
            params,
            paramsSerializer: params => {
                return qs.stringify(params, {
                    arrayFormat: 'repeat' //转换后的数组格式
                })
            },
        }).then((res) => {
            reslove(res)
        }).catch(err => {
            reject(err)
        })
    })
}

//申请
export function apply(data) {
    return new Promise((reslove, reject) => {
        axios({
            url: api.customerhighseaApi.customerhighsea.CUSTOMERHIGHSEA_APPLY,
            method: 'post',
            headers: {
                'Content-Type': 'application/json'
            },
            data,
        }).then((res) => {
            reslove(res)
        }).catch(err => {
            reject(err)
        })
    })
}